<?php if (!defined('BASEPATH')) exit('No direct script access allowed'); ?>
<?php $this->load->view('common/head'); ?>

<?php $this->load->view('common/header'); ?>
<div class="main-container" id="main-container">
    <script type="text/javascript">
        try {
            ace.settings.check('main-container', 'fixed')
        } catch (e) {
        }
    </script>

    <?php $this->load->view('common/sidebar'); ?>
    <div class="main-content">
        <div class="main-content-inner">
            <!-- #section:basics/content.breadcrumbs -->
            <?php $this->load->view('common/breadcrumbs'); ?>

            <!-- /section:basics/content.breadcrumbs -->
            <div class="page-content">

                <?php $this->load->view('common/set'); ?>
                <div class="page-header">
                    <h1>
                        <?= $order['order_type_name'] ?>
                        <small>
                            <i class="ace-icon fa fa-angle-double-right"></i>
                            <?= $order['order_state_name'] ?>
                        </small>
                    </h1>
                </div>
                <!-- /section:settings.box -->
                <div class="row">
                    <div class="col-xs-12" style="margin-top: 15px;">
                        <div class="profile-user-info profile-user-info-striped">
                            <div class="profile-info-row">
                                <div class="profile-info-name"> 订单ID</div>
                                <div class="profile-info-value">
                                    <span class="editable editable-click" id="username"><?= $order['id'] ?></span>
                                </div>
                            </div>
                            <div class="profile-info-row">
                                <div class="profile-info-name"> 订单号</div>
                                <div class="profile-info-value">
                                    <span class="editable editable-click"
                                          id="username"><?= $order['external_order_no'] ?></span>
                                </div>
                            </div>
                            <div class="profile-info-row">
                                <div class="profile-info-name"> 订单类型</div>
                                <div class="profile-info-value">
                                    <span class="editable editable-click"
                                          id="username"><?= $order['order_type_name'] ?></span>
                                </div>
                            </div>
                            <div class="profile-info-row">
                                <div class="profile-info-name"> 订单价格</div>
                                <div class="profile-info-value">
                                    <span class="editable editable-click"
                                          id="username"><?= $order['order_price'] ?></span>
                                </div>
                            </div>
                            <div class="profile-info-row">
                                <div class="profile-info-name"> 产品</div>
                                <div class="profile-info-value">
                                    <span class="editable editable-click"
                                          id="username"><?= $order['routes'] ?></span>
                                </div>
                            </div>
                            <div class="profile-info-row">
                                <div class="profile-info-name"> 订单来源</div>
                                <div class="profile-info-value">
                                    <span class="editable editable-click"
                                          id="username"><?= $order['order_from'] ?></span>
                                </div>
                            </div>
                            <div class="profile-info-row">
                                <div class="profile-info-name"> 订单状态</div>
                                <div class="profile-info-value">
                                    <span class="editable editable-click" id="username">
                                        <?php if ($order['order_status'] == 0) { ?>
                                            <span class="label label-sm label-warning arrowed arrowed-righ"><?= $order['order_state_name'] ?></span>
                                        <?php } ?>
                                        <?php if ($order['order_status'] < 5 && $order['order_status'] > 0) { ?>
                                            <span class="label label-sm label-info arrowed arrowed-righ"><?= $order['order_state_name'] ?></span>
                                        <?php } ?>
                                        <?php if ($order['order_status'] == 5) { ?>
                                            <span class="label label-sm label-success arrowed arrowed-righ"><?= $order['order_state_name'] ?></span>
                                        <?php } ?>
                                        <?php if ($order['order_status'] == 6) { ?>
                                            <span class="label label-sm label-success arrowed arrowed-righ"><?= $order['order_state_name'] ?></span>
                                        <?php } ?>
                                    </span>
                                </div>
                            </div>
                            <div class="profile-info-row">
                                <div class="profile-info-name"> 下单时间</div>
                                <div class="profile-info-value">
                                    <span class="editable editable-click"
                                          id="username"><?= $order['create_time'] ?></span>
                                </div>
                            </div>
                            <div class="profile-info-row">
                                <div class="profile-info-name"> 接单司机</div>
                                <div class="profile-info-value">
                                    <span class="editable editable-click"
                                          id="username"><?= $order['user_name'] ?></span>
                                </div>
                            </div>
                            <div class="profile-info-row">
                                <div class="profile-info-name"> 接单时间</div>
                                <div class="profile-info-value">
                                    <span class="editable editable-click" id="username"><?= $order['rob_time'] ?></span>
                                </div>
                            </div>
                        </div>
                    </div>

                </div><!-- /.row -->
                <div class="page-header">
                    <h1>
                        <small>
                            <i class="ace-icon fa fa-angle-double-right"></i>
                            订单详细
                        </small>
                    </h1>
                </div>
                <!-- /section:settings.box -->
                <div class="row">
                    <div class="profile-user-info profile-user-info-striped">
                        <div class="profile-info-row">
                            <div class="profile-info-name"> 订单价格</div>
                            <div class="profile-info-value">
                                <span class="editable editable-click"
                                      id="username"><?= $order['order_price'] ?? ""; ?></span>
                            </div>
                        </div>
                        <div class="profile-info-row">
                            <div class="profile-info-name"> 出发时间</div>
                            <div class="profile-info-value">
                                <span class="editable editable-click"
                                      id="username"><?= $order['start_time'] ?? ""; ?></span>
                            </div>
                        </div>
                        <div class="profile-info-row">
                            <div class="profile-info-name"> 车型要求</div>
                            <div class="profile-info-value">
                                <span class="editable editable-click"
                                      id="username"><?= $order['car_seat_format'] ?? ""; ?></span>
                            </div>
                        </div>
                        <div class="profile-info-row">
                            <div class="profile-info-name"> 航班号</div>
                            <div class="profile-info-value">
                                <span class="editable editable-click"
                                      id="username"><?= $order['plane_no'] ?? ""; ?></span>
                            </div>
                        </div>
                        <div class="profile-info-row">
                            <div class="profile-info-name"> 出发地</div>
                            <div class="profile-info-value">
                                <span class="editable editable-click"
                                      id="username"><?= $order['departure_address'] ?? ""; ?></span>
                            </div>
                        </div>
                        <div class="profile-info-row">
                            <div class="profile-info-name"> 目的地</div>
                            <div class="profile-info-value">
                                <span class="editable editable-click"
                                      id="username"><?= $order['destination_address'] ?? ""; ?></span>
                            </div>
                        </div>
                        <div class="profile-info-row">
                            <div class="profile-info-name"> 乘客数量</div>
                            <div class="profile-info-value">
                                <span class="editable editable-click"
                                      id="username"><?= $order['pasengers'] ?? ""; ?></span>
                            </div>
                        </div>
                        <div class="profile-info-row">
                            <div class="profile-info-name"> 行李描述</div>
                            <div class="profile-info-value">
                                <span class="editable editable-click"
                                      id="username"><?= $order['packages'] ?? ""; ?></span>
                            </div>
                        </div>
                        <div class="profile-info-row">
                            <div class="profile-info-name"> 联系人</div>
                            <div class="profile-info-value">
                                <span class="editable editable-click"
                                      id="username"><?= $order['contact_name'] ?? ""; ?></span>
                            </div>
                        </div>
                        <div class="profile-info-row">
                            <div class="profile-info-name"> 联系电话</div>
                            <div class="profile-info-value">
                                <span class="editable editable-click"
                                      id="username"><?= $order['contact_mobile'] ?? ""; ?></span>
                            </div>
                        </div>
                        <div class="profile-info-row">
                            <div class="profile-info-name"> 微信</div>
                            <div class="profile-info-value">
                                <span class="editable editable-click"
                                      id="username"><?= $order['contact_wechat'] ?? ""; ?></span>
                            </div>
                        </div>
                        <div class="profile-info-row">
                            <div class="profile-info-name"> 邮箱</div>
                            <div class="profile-info-value">
                                <span class="editable editable-click"
                                      id="username"><?= $order['contact_eamil'] ?? ""; ?></span>
                            </div>
                        </div>
                        <div class="profile-info-row">
                            <div class="profile-info-name"> 备注</div>
                            <div class="profile-info-value">
                                <span class="editable editable-click"
                                      id="username"><?= $order['remark'] ?? ""; ?></span>
                            </div>
                        </div>
                        <div class="profile-info-row">
                            <div class="profile-info-name"> 添加人</div>
                            <div class="profile-info-value">
                                <span class="editable editable-click"
                                      id="username"><?= $order['admin_name'] ?? "--"; ?></span>
                            </div>
                        </div>

                    </div>

                </div>
                <div class="page-header">
                    <h1>
                        <small>
                            <i class="ace-icon fa fa-angle-double-right"></i>
                            参与抢单人员
                        </small>
                    </h1>
                </div>
                <!-- /section:settings.box -->
                <div class="row">
                    <div class="col-xs-12" style="margin-top: 15px;">
                        <table class="table table-striped table-bordered">
                            <thead>
                            <tr>
                                <th>姓名</th>
                                <th>用户名</th>
                                <th>服务类型</th>
                                <th>服务位置</th>
                                <th>电话</th>
                                <th>坐席</th>
                                <th>抢单时间</th>
                                <th>积分</th>
                                <th>抢单结果</th>
                                <th>手动派单</th>
                            </tr>
                            </thead>
                            <tbody>
                            <?php if (isset($robers) && !empty($robers)) {
                                foreach ($robers as $key => $val) { ?>
                                    <tr>
                                        <td><?= $val['user_uname'] ?></td>
                                        <td><?= $val['user_name'] ?></td>
                                        <td><?= $val['user_service_type'] ?></td>
                                        <td class="grouptd">
                                            <span class="label label-sm label-inverse arrowed-in"><?= $val['user_dress'] ?></span>
                                        </td>
                                        <td><?= $val['user_tel'] ?></td>
                                        <td><?= $val['car_seat_format'] ?></td>
                                        <td>
                                            <?= $val['create_at']; ?>
                                        </td>
                                        <td><?= $val['user_credit'] ?></td>
                                        <td>
                                            <?php if ($val['result'] == 0) { ?>
                                                【等待派单】
                                            <?php } ?>
                                            <?php if ($val['result'] == 1) { ?>
                                                <span class="label label-sm label-success">抢单成功</span>
                                            <?php } ?>
                                            <?php if ($val['result'] == 2) { ?>
                                                <span class="label label-sm label-warning">抢单失败</span>
                                            <?php } ?>
                                        </td>
                                        <td>
                                            <?php if ($order['order_status'] == 0) { ?>
                                                <a class="distribution" href="javascript:;"
                                                   data-url="<?= site_url(X_URL . 'OrderCar/distribution'); ?>"
                                                   data-id="<?= $val['user_id'] ?>"
                                                   data-order="<?php echo $val['order_id']; ?>">指派给他</a>&nbsp;
                                            <?php } else { ?>
                                                --
                                            <?php } ?>
                                        </td>
                                    </tr>
                                <?php } ?>
                            <?php } ?>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div><!-- /.page-content -->
        </div>
    </div><!-- /.main-content -->
</div><?php $this->load->view('common/footer'); ?>


<?php $this->load->view('common/footerjs'); ?>
<!-- inline scripts related to this page -->
<?php echo admin_js_url('laydate'); ?>
<script>
    laydate.render({
        elem: '#start_time' //指定元素
        , type: "datetime"
    });
    $(".distribution").click(function () {
        var url = $(this).attr('data-url');
        var order_id = $(this).attr('data-order');
        var user_id = $(this).attr('data-id');
        layer.confirm('确定分派给改用户吗？', {
            btn: ['确定', '取消'] //按钮
        }, function () {
            $.ajax({
                type: "post",
                url: url,
                data: {'order_id': order_id, 'user_id': user_id, 'csrf_test_name': ci_csrf_token()},
                dataType: "JSON",
                success: function (msg) {
                    if (msg.status == 1) {
                        layer.msg(msg.info, {
                            time: 1000, //1s后自动关闭
                            shade: 0.1,
                            icon: 1
                        }, function () {
                            window.location.reload();
                        });
                    } else {
                        layer.msg(msg.info, {
                            time: 1000, //1s后自动关闭
                            shade: 0.1
                        });
                        return false;
                    }
                }
            })
        }, function () {
        });
    });
</script>
</body>
</html>
